import 'package:flutter_shop/pages/base/base_presenter.dart';
import 'package:flutter_shop/pages/home/home_tab_page/entity/home_hot_data.dart';
import 'package:flutter_shop/pages/home/home_tab_page/home_tab_contract.dart';
import 'package:flutter_shop/pages/home/home_tab_page/home_tab_model.dart';

/// Title:HomeTabPresenter <br/>
/// Description: <br/>
/// author:Administrator <br/>
/// date: 2020-03-08  <br/>
/// version 1.0 <br/>
class HomeTabPresenter extends BasePresenter<HomeTabView> {
  HomeModel mModel = HomeModel();

  ///请求获取首页数据
  void getHomeContent() {
    mModel.getHomeContent().then((val) {
      mView.showPageData(val);
    }).catchError((error) {
      mView.showError(error.message);
    });
  }

  ///获取首页火爆专区数据
  void getHotGoods(int currentIndex) {
    mModel.getHomeHotList(currentIndex).then((val) {
      if (val == null) {
        val = List<HomeHotData>();
      }
      mView.showHotData(val);
    }).catchError((error) {
      mView.showError(error.message);
    });
  }
}
